/**
 * 
 */
package peerToPeerFacebook.proj;

import java.io.Serializable;

/** Packet class that represents RPC Invoke message that needs to go over network. 
 * 
 */
public class RPCInvokePacket extends RPCPacketBase 
{
	private static final long serialVersionUID = 2L;

	/** Name of the method to invoke */
	public String method;
	
	/** Arguments for method invocation */
	public Serializable[] params;
	
	/** Constructs invoke packet. Sets action to invoke
	 * 
	 * @param sequenceID Sequence ID to use
	 * @param method Method name
	 * @param params Parameters to pass to the method
	 */
	public RPCInvokePacket(long sequenceID, String method, Serializable[] params)
	{
		super(sequenceID, RPCPacketBase.Action.Invoke);
		
		this.method = method;
		this.params = params;
	}
	
	/** Build nice representation of the packet. Namely adds method name and parameter types
	 */
	@Override
	public String toString()
	{
		StringBuilder paramNames = getStringDefinition(params);				
		return super.toString() + ", " + method + "(" + paramNames + ")";
	}
}
